/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.indicator;

import com.tictactec.ta.lib.MAType;
import org.amuthu.DataStore;
import org.amuthu.TalibMgr;

/**
 *
 * @author prabhu
 */
public class PercentagePriceOscillator extends Indicator
{
   private int fastPeriod;
   private int slowPeriod;

   /**
    *
    * @param dataStore
    * @param fastPeriod
    * @param slowPeriod
    * @param startOffset
    */
   public PercentagePriceOscillator(DataStore dataStore, int fastPeriod, int slowPeriod, int startOffset)
   {
      super(dataStore, startOffset);
      this.fastPeriod = fastPeriod;
      this.slowPeriod = slowPeriod;
   }

   /**
    *
    * @return
    */
   @Override
   public double calculate()
   {
      int lastIdx = getLastIndex();

      TalibMgr.getTalib().ppo(lastIdx,
                              lastIdx,
                              getDataStore().getClose(),
                              fastPeriod,
                              slowPeriod,
                              MAType.Ema,
                              TalibMgr.getOutBeginIdx(),
                              TalibMgr.getOutNbElement(),
                              getResultArray());

      return getResultValue();
   }

   @Override
   public int getDayDependency()
   {
      return TalibMgr.getTalib().ppoLookback(fastPeriod, slowPeriod, MAType.Ema) + startOffset;
   }

}
